﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        div {
            width: 100px;
            height: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div>

    </div>
    <script>
        var div = document.querySelector("div");
        // var x = div.getBoundingClientRect().x;
        // var y = div.getBoundingClientRect().y;
        // var w = div.getBoundingClientRect().width;
        // var h = div.getBoundingClientRect().height;

        var { x, y, width, height } = div.getBoundingClientRect();
        console.log(y);


        var obj = {
            name: "lili",
            age: 18,
        }
        // var name = obj.name;
        // var age = obj.age;

        // 得到obj这个对象中name属性与age属性的值赋值给全局变量name与age
        // 变量名需要与属性名一样

        // var {age,name} = obj;
        // 给全局变量定义新的名称 (属性名:变量名) = 对象
        var { age: a, name: n } = obj;
        // console.log(n); //lili
        // console.log(a); //18


        var arr = [12, 23, 34, 45, ["a", "b"]];
        // console.log(arr[2]);
        var [a, b, c, d, [e, f]] = arr;
        console.log(a);
        console.log(e);
    </script>
</body>
</html>